#include "CFrame.h"

CFrame::CFrame()
{
    iLeft = iTop = iBottom = iRight = 0;
}

CFrame::CFrame(int iLeftP, int iTopP, int iRightP, int iBottomP)
{
    iLeft   = iLeftP;
    iTop    = iTopP;
    iRight  = iRightP;
    iBottom = iBottomP;
}

CFrame::CFrame(const CFrame& FramePam)
{
    iLeft   = FramePam.iLeft;
    iTop    = FramePam.iTop;
    iRight  = FramePam.iRight;
    iBottom = FramePam.iBottom;
}

int CFrame::GetWidth()
{
    return iRight - iLeft;
}

int CFrame::GetHeight()
{
    return iBottom - iTop;
}

bool CFrame::IsValid()
{
    return (iBottom >= iTop && iRight >= iLeft);
}

bool CFrame::Collide(const CFrame& Frame)
{
    return((iLeft < Frame.iRight)  && (iRight  > Frame.iLeft) &&
           (iTop  < Frame.iBottom) && (iBottom > Frame.iTop));
}


SDL_Rect CFrame::GetSDLRect()
{
    SDL_Rect Rect;

    Rect.x = iLeft;
    Rect.y = iTop;
    Rect.h = GetHeight();
    Rect.w = GetWidth();

    return Rect;
}




